<?php
/**
 * @author Pawel Giemza
 * @version 1.0
 * @package Arrow
 * @subpackage Orm
 * @link http://arrowplatform.org/
 * @copyright 2009 3code 
 * @license GNU LGPL
 * 
 * @date 2009-03-06 
*/

/**
 * Interface for accessing databases.
 */
interface ArrowOrmDb
{
	
	/**
	 * Constuctor. Opens connection to DB
	 *
	 * @param String $host
	 * @param String $user
	 * @param String $password
	 * @param String $dbname
	 * @param String $charset	 
	 * @param bool $transaction
	 * @param String $alias
	 */	
	public function __construct($host, $user, $password, $dbname, $charset, $transaction, $alias);
	
	/**
	 * Destructor. Closes connection to DB.
	 */	
	public function destruct();
	
	/**
	 * SQL select statement.
	 *
	 * @param String $table - table name
	 * @param Array $columns - list of columns (from Config)
	 * @param Criteria $criteria
	 * @param Selector $selector
	 */
	public function select($table, $criteria);	
	
	/**
	 * SQL insert statement
	 *
	 * @param String $table - table name
	 * @param Array $data - key,value pairs to be inserted into DB
	 */
	public function insert($table, $data);
	
	/**
	 * SQL update statement
	 *
	 * @param String $table - table name
	 * @param Array $data - key,value pairs to be updated
	 * @param Criteria $criteria - Criteria object with id of record(s) to be updated
	 */
	public function update($table, $data, $criteria);
	
	/**
	 * SQL delete statement
	 *
	 * @param String $table - table name
	 * @param Criteria $criteria - Criteria describing objects to be deleted
	 */
	public function delete($table, $criteria);
	
	/**
	 * Custom query
	 *
	 * @param String $query - query to be executed
	 */
	public function query($query, $multiInsert=false);
	

	public function conditionsToSQL($criteria);


	public function columnsToSQL($criteria);
	

	public function groupsToSQL($criterias);	

	/**
	 * 
	 * zwraca dotychczasowy czas wykonania zapytań - od momenty włączenia 
	 * @param bool $onoff - włącz/wyłącz
	 */
	public static function executionTime( $onoff = true ) ;
}

?>